import os
# 
from wand.image import Image as wima

folder='D:/Undergraduate_Lectures/cfd-course-cug/Textbook/FDM/media-af'

for oldfilename in os.listdir(folder):
    if oldfilename.endswith(".wmf"):
        with wima(filename=folder+'/'+oldfilename) as img:
            newfilename = oldfilename.split('.')[0]+'.png'
            newfilename = folder+'/'+newfilename
            img.format = 'png'
            img.save(filename=newfilename)